package com.example.combination;

import android.view.View;
import android.view.ViewGroup;
import android.view.animation.RotateAnimation;

import androidx.constraintlayout.widget.ConstraintLayout;

/**
 * author：sunweihao
 * 创建时间：2021/1/8 21:46
 * Describe：是否显示工具类
 */
public class Tool {
    public static void hideView(ViewGroup view) {
        RotateAnimation rotateAnimation=new RotateAnimation(0,180,view.getWidth()/2,view.getHeight());
        rotateAnimation.setDuration(500);
        rotateAnimation.setFillAfter(true);
        view.startAnimation(rotateAnimation);
        view.setEnabled(false);
        for (int i = 0; i < view.getChildCount(); i++) {
            View childAt = view.getChildAt(i);
            childAt.setEnabled(false);
        }
    }
    public static void hideView(ViewGroup view, int startOfTime) {
        RotateAnimation rotateAnimation=new RotateAnimation(0,180,view.getWidth()/2,view.getHeight());
        rotateAnimation.setDuration(500);
        rotateAnimation.setFillAfter(true);
        rotateAnimation.setStartOffset(startOfTime);
        view.startAnimation(rotateAnimation);
        view.setEnabled(false);
        for (int i = 0; i < view.getChildCount(); i++) {
            View childAt = view.getChildAt(i);
            childAt.setEnabled(false);
        }
    }
    public static void show(ViewGroup view) {
        RotateAnimation rotateAnimation=new RotateAnimation(180,0,view.getWidth()/2,view.getHeight());
        rotateAnimation.setDuration(500);
        rotateAnimation.setFillAfter(true);
        view.startAnimation(rotateAnimation);
        view.setEnabled(true);
        for (int i = 0; i < view.getChildCount(); i++) {
            View childAt = view.getChildAt(i);
            childAt.setEnabled(true);
        }
    }


}
